﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Data;
using log4net;
using Services.Interface;

namespace Services.Implement
{
    public class InitPageService:IInitPageService
    {
        private IIndexVisitingInfoRepositery indexVisitingInfoRepositery;
        private IShareVisitingInfoRepositery shareVisitingInfoRepositery;
        private ICarRepositery carRepositery;
        private IUserRepositery UserRepository;

        private ILog Logger;

        public InitPageService()
        {
            indexVisitingInfoRepositery = DataRepositeryManagerFactory.CreateIndexVisitingInfoRepositery();
            shareVisitingInfoRepositery = DataRepositeryManagerFactory.CreateShareVisitingInfoRepositery();
            carRepositery = DataRepositeryManagerFactory.CreateCarRepositery();
            UserRepository = DataRepositeryManagerFactory.CreateUserRepositery();
            Logger = LogManager.GetLogger(this.GetType());
        }

        public List<Car> GetCarList()
        {
            return carRepositery.GetCars();
        }

        public bool AddIndexRecord(string IP)
        {
            return indexVisitingInfoRepositery.Record(IP);
        }

        public bool AddShareRecord(string IP)
        {
            return shareVisitingInfoRepositery.Record(IP);
        }

        public List<User> GetTopUsers(int num)
        {
            return UserRepository.GetTopChargingUsers(num);
        }
    }
}
